StringToShort Function

public function StringToShort(string, error) result(number)

Converts number string to a short integer Arguments: string String to be converted Result: short integer

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: string
logical, intent(out), optional :: error

Return Value integer(kind=short)


Variables

Type Visibility Attributes Name Initial
integer(kind=short), public :: ios

Source Code

FUNCTION StringToShort &
  ( string, error )           &
RESULT (number)

IMPLICIT NONE

! Function arguments
! Scalar arguments with intent(in):
CHARACTER(LEN = *), INTENT (IN)  :: string

!Arguments with intent (out).
LOGICAL, OPTIONAL, INTENT(OUT) :: error

! Local scalars:
INTEGER (KIND = short)  :: number
INTEGER (KIND = short)  :: ios 

!------------end of declaration------------------------------------------------

READ (string,*,iostat = ios) number

IF (PRESENT (error)) THEN
   error = .FALSE.
   IF ( ios /= 0 ) THEN
     error = .TRUE.
     RETURN
   END IF
ELSE
   IF ( ios /= 0 ) THEN
     CALL Catch ('error', 'StringManipulation', 'converting string to &
               short integer ', code = genericIOError, argument = string )
   END IF
END IF

END FUNCTION StringToShort